|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPER.rover.control.RoverController
Allows communication with and control of the robot. Generally programs should access the functions in RoverController through its subclass, Rover.
For all of the functions in this class that set the motor speeds, the speed should be a number in the range of [-255, 255]. On the cerebellum this is represented by an 8-bit number and a sign bit. This speed is the pulse width that the motors are getting. If the pulse is less than 50% duty cycle, the motors won't turn on. Therefore, if you want the rover to go backwards, set the speed to be between -129 and -255. If you want the rover to go forwards, set the speed to be between 129 and 255. The motor changes speed roughly linearly withing these ranges. Speeds outside of the range [-255, 255] are capped.
Field Summary | |
RoverState |
highLevelState
This instance of the state is updated only by goTo, turnTo, killHighLevel, and updateHighLevel. |
static int |
READ_TIMEOUT
The time in ms of how long to wait for the rover to respond. |
ReceiveThread |
receive
This class contains images sent back during DriveTo and TurnTo as well as tracking data. |
Reliagram |
reliagram
|
RoverState |
state
This instance of the state is updated whenever you call a simple command. |
Constructor Summary | |
RoverController()
Creates a new RoverController |
Method Summary | |
boolean |
closeComm()
Closes communication with the rover. |
static int |
compareVersion(java.lang.String version1,
java.lang.String version2)
Compares two version strings. |
boolean |
crab(int speed,
int angle)
Moves the rover in a straight line at the specified angle. |
java.lang.String |
getCalibration()
This funciton is useful if you want to see the servo calibration on the rover. |
int[] |
getCameraProperties()
Gets information on the state of the camera. |
int |
getDriveCalibration()
Loads the calibration file from the rover and returns the drive adjustment value. |
boolean |
getMean(boolean stream)
Gets the mean for the red, green and blue channels. |
java.lang.String |
getScanList()
This funciton is useful if you want to see the scan calibration on the rover. |
int |
getTurnCalibration()
Loads the calibration file from the rover and returns the turn adjustment value. |
java.lang.String |
getVersion()
Gets the version of the code running on the Stargate as a String. |
boolean |
goTo(int dist,
int angle)
This command starts the rover to go the specified distance while driving at the specified angle. |
boolean |
goTo(int dist,
int angle,
byte safetyLevel,
boolean takePics)
This command starts the rover to go the specified distance while driving at the specified angle. |
boolean |
headMove(boolean doPan,
int pan,
boolean doTilt,
int tilt)
This function is just like the look command, but you can specify whether you want to move ther servo or not. |
boolean |
initComm(java.lang.String ipaddr)
Initializes the communication with the robot but does not check that the rover is on or that it is responding. |
boolean |
initRobot()
Initalizes the rover; centers all of the servos and sets wheel velocities to zero. |
boolean |
isConnected()
Returns true if connected to a robot. |
boolean |
killHighLevel()
This function will kill any currently running turnTo, goTo or scan. |
boolean |
killRobot()
Kills anything the rover is doing by calling initRobot. |
boolean |
look(int pan,
int tilt)
Moves the pan and tilt on the PER. |
boolean |
quadTurn(int speed,
int radius)
This function has the rover move and rotate about the point (0, radius) in the rover's reference frame. |
boolean |
refresh()
This command refreshes the state of the robot. |
int[] |
scan(int tilt,
int minPan,
int maxPan,
int step)
Scans the area around where the rover is. |
boolean |
setAll(int mask,
int rightMotor,
int leftMotor,
int frontLeftServo,
int frontRightServo,
int backRightServo,
int backLeftServo,
int pan,
int tilt)
Allows you to directly set the positions of the motors and servos. |
boolean |
setCalibration(java.lang.String cal)
Sets the calibration file on the robot. |
boolean |
setLight(boolean on)
This function allows you to turn the UV light on the rover on or off. |
boolean |
setPan(int pan)
This command is just like look, but only sets the pan. |
boolean |
setScanList(java.lang.String cal)
This funciton sets the scan calibration on the rover. |
boolean |
setTilt(int tilt)
This command is just like look, but only sets the tilt. |
boolean |
spin(int speed)
Turns the rover about its center point. |
boolean |
startMotionDetection()
Starts the rover detection motion. |
boolean |
startTrack(int minY,
int maxY,
int minU,
int maxU,
int minV,
int maxV)
Starts the rover tracking an object. |
boolean |
startTrack(int minY,
int maxY,
int minU,
int maxU,
int minV,
int maxV,
int trackMethod,
boolean movePan,
boolean moveTilt,
int driveMethod)
Starts the rover tracking an object. |
boolean |
stopStreaming()
Stops the rover's camera commands that stream which include getMean and tracking. |
java.awt.image.BufferedImage |
takePicture(int pan,
int tilt,
int width,
int height)
This function is the same as the other takePicture function, but has the UV light off. |
java.awt.image.BufferedImage |
takePicture(int pan,
int tilt,
int width,
int height,
boolean lightUV)
Tries to take a picture. |
byte[] |
takeRawPicture(int pan,
int tilt,
int width,
int height)
This function returns the raw YUV that the camera returns. |
java.awt.image.BufferedImage |
takeRecentPicture()
Gives you the most recent picture that was taken by the rover. |
boolean |
turnTo(int degrees)
This command starts the rover to turn the specified number of degrees. |
boolean |
turnTo(int degrees,
boolean takePics)
This command starts the rover to turn the specified number of degrees. |
boolean |
updateHighLevel()
This function is intended for use in PER.rover.DriveToAction and PER.rover.TurnToAction. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public RoverState state
public RoverState highLevelState
public ReceiveThread receive
public Reliagram reliagram
public static final int READ_TIMEOUT
Constructor Detail |
public RoverController()
Method Detail |
public boolean initComm(java.lang.String ipaddr)
ipaddr
- An IP address or hostname.
public boolean closeComm()
public boolean isConnected()
public boolean initRobot()
public boolean killRobot()
initRobot()
public java.awt.image.BufferedImage takePicture(int pan, int tilt, int width, int height, boolean lightUV)
state
is set.
pan
- The pan value in degrees at which to take the picture.tilt
- The tilt vale in degrees at which to take the picture.width
- The width of the image in pixels.height
- The hiehgt of the image in pixels.
public java.awt.image.BufferedImage takePicture(int pan, int tilt, int width, int height)
public byte[] takeRawPicture(int pan, int tilt, int width, int height)
public java.awt.image.BufferedImage takeRecentPicture()
state
is set.
public int[] scan(int tilt, int minPan, int maxPan, int step)
state
is set.
tilt
- The tilt at which the scan is done.minPan
- The pan angle at which the scan startsmaxPan
- The pan angle at which the scan ends.step
- The angle difference between successive scan points.
(maxPan-minPan+step)/step
points in the array.public boolean goTo(int dist, int angle)
dist
- How many centimenters to driveangle
- The angle for the rover to drive at. This angle must be in
the range of [-90, 90] or else you will get a BAD_INPUT error.DriveToAction
public boolean goTo(int dist, int angle, byte safetyLevel, boolean takePics)
highLevelState
dist
- How many centimenters to driveangle
- The angle for the rover to drive at. This angle must be in
the range of [-90, 90] or else you will get a BAD_INPUT error.safetyLevel
- See constants at top of PER.rover.DriveToActionDriveToAction
public boolean turnTo(int degrees, boolean takePics)
highLevelState
degrees
- How many degrees to turn, with positive being to the lefttakePics
- Whether or not to take pictures while driving.DriveToAction
public boolean turnTo(int degrees)
highLevelState
degrees
- How many degrees to turn, with positive being to the leftDriveToAction
public boolean killHighLevel()
KILLED
This function will always update the information in highLevelState
public boolean updateHighLevel()
highLevelState
public int getDriveCalibration()
goTo
commands work the same from rover to rover despite variation in the drive
motors. The adjustment value is a percentage. A value below 100 means drive
for a shorter time. A value above 100 means drive for a longer time.
Because crab
and quadTurn
do not make use of the
drive calibration, programs that use these commands may want to want to use
getDriveCalibration
to ensure that the program behaves the
same from rover to rover.
This function will only update the status in state
in case of error.
public int getTurnCalibration()
turnTo
commands work the same from rover to rover despite variation in the drive
motors. The adjustment value is a percentage. A value below 100 means turn
for a shorter time. A value above 100 means turn for a longer time.
Because spin
does not make use of the turn calibration,
programs that use spin
may want to want to use
getTurnCalibration
to ensure that the program behaves the
same from rover to rover.
This function will only update the status in state
in case of error.
public java.lang.String getCalibration()
state
in case of error.
public boolean setCalibration(java.lang.String cal)
state
cal
- The calibration file as a String.
public java.lang.String getScanList()
state
in case of error.
public boolean setScanList(java.lang.String cal)
state
cal
- The scan calibration file as a String.
public boolean look(int pan, int tilt)
state
pan
- The pan angle in degrees for the PER to move its head to. This value should
be in the range of [-180, 180]. If you choose an angle outside of this range,
the pan will be set to the closest valid value. Positive angles are to the left.tilt
- The tilt angle in degrees for the PER to move its head to. This value should
be in the range of [-50, 90]. If you choose an angle outside of this range,
the tilt will be set to the closest valid value.
public boolean setPan(int pan)
pan
- The desired pan angle.
look(int, int)
public boolean setTilt(int tilt)
tilt
- The desired tilt angle.
look(int, int)
public boolean refresh()
public boolean headMove(boolean doPan, int pan, boolean doTilt, int tilt)
public boolean setAll(int mask, int rightMotor, int leftMotor, int frontLeftServo, int frontRightServo, int backRightServo, int backLeftServo, int pan, int tilt)
state
mask
- An 8-bit mask specifying which of these parameters you want to
set. 1 is the mask for the rightMotor, 2 for the leftMotor,
. . . 128 for the tilt servo.rightMotor
- The motor speed for the right motor.leftMotor
- The motor speed for the left motor.frontLeftServo
- The servo position for the front left servo.frontRightServo
- The servo position for the front right servo.backRightServo
- The servo position for the back right servo.backLeftServo
- The servo position for the back left servo.pan
- The servo postition for the pan servo.tilt
- The servo postition for the tilt servo.public boolean spin(int speed)
state
speed
- How fast to go - see comments at top of file for more explaination.
public boolean crab(int speed, int angle)
state
speed
- How fast to go - see comments at top of file for more explaination.angle
- The angle the steering servos are set to. Angles outside of
the valid range of [-90, 90] are capped.
public boolean quadTurn(int speed, int radius)
state
speed
- How fast to go - see comments at top of file for more explaination.radius
- The radius to turn around.
public boolean setLight(boolean on)
state
on
- If true, the light will turn on, if false, the light will turn off.
public java.lang.String getVersion()
public static int compareVersion(java.lang.String version1, java.lang.String version2) throws java.lang.NumberFormatException
version1
- The first string to compareversion2
- The second string to compare
java.lang.NumberFormatException
public boolean startTrack(int minY, int maxY, int minU, int maxU, int minV, int maxV)
receive
.
By default, it tracks the largest blob, moving only pan and tilt, and doesn't drive.
minY
- The minimum Y value to track.maxY
- The maximum Y value to track.minU
- The minimum U value to track.maxU
- The maximum U value to track.minV
- The minimum V value to track.maxV
- The maximum V value to track.
public boolean stopStreaming()
state
public boolean startTrack(int minY, int maxY, int minU, int maxU, int minV, int maxV, int trackMethod, boolean movePan, boolean moveTilt, int driveMethod)
receive
.
This function will always update the information in state
minY
- The minimum Y value to track.maxY
- The maximum Y value to track.minU
- The minimum U value to track.maxU
- The maximum U value to track.minV
- The minimum V value to track.maxV
- The maximum V value to track.trackMethod
- Controls how the object is tracked. 0=biggest blobmovePan
- If set to true, it will move the pan angle to try and center the object tracked.moveTilt
- If set to true, it will move the tilt angle to try and center the object tracked.driveMethod
- Currently not supported.
public int[] getCameraProperties()
The function works by calling VIDIOCSPICT and returns the contents of the
struct video_picture.
This function will only update the status in state
in case of error.
public boolean getMean(boolean stream)
receive
.
This function will always update the information in state
stream
- If set to true, the rover will stream the data back until
stopStreaming() is called. If set to false, the rover will send back
the current mean values and then quit.
public boolean startMotionDetection()
receive
.
This function will always update the information in state
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |